home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programmer's Power Pack / Delphi Volume 1.iso / e_to_l / edsspell / edsdb.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-09-15  |  2.0 KB  |  81 lines

  1. unit EDSDB;
  2. interface
  3. uses
  4.   SysUtils, WinTypes, WinProcs, Messages, Classes, Controls, Graphics, Forms,
  5.   Menus, StdCtrls, ExtCtrls,DBCtrls, DBGrids;
  6.  
  7. type
  8.   TDBEnterEdit = class(TDBEdit)
  9.     private
  10.       { Private declarations }
  11.     protected
  12.       { Protected declarations }
  13.       procedure KeyPress(var Key: Char); override;
  14.       procedure KeyDown (var Key: Word; Shift: TShiftState);  override;
  15.     public
  16.       { Public declarations }
  17.     published
  18.       { Published declarations }
  19.   end;  { TDBEnterEdit }
  20.  
  21.   TNewDBGrid = class (TDBGrid)
  22.     private
  23.       { Private declarations }
  24.       FOnClick : TNotifyEvent;
  25.       procedure Click; override;
  26.     published
  27.       { Published declarations }
  28.       property OnClick : TNotifyEvent read FOnClick write FOnClick;
  29.   end;  { TNewDBGrid }
  30.  
  31. procedure Register;
  32.  
  33. implementation
  34.  
  35. procedure TDBEnterEdit.KeyPress(var Key: Char);
  36. var
  37.    MYForm: TForm;
  38. begin
  39.   if Key = #13 then
  40.   begin
  41.     MYForm := GetParentForm( Self );
  42.     if not (MYForm = nil ) then
  43.         SendMessage(MYForm.Handle, WM_NEXTDLGCTL, 0, 0);
  44.     Key := #0;
  45.   end;  { if... }
  46.   if Key <> #0 then inherited KeyPress(Key);
  47. end;  { TDBEnterEdit.KeyPress }
  48.  
  49. procedure TDBEnterEdit.KeyDown (var Key: Word; Shift: TShiftState);
  50. var
  51.   St: string;
  52. begin
  53.   case Key of
  54.     VK_UP: if ssCtrl in Shift then
  55.            begin
  56.              Text := UpperCase (Text);
  57.              Key  := 0;
  58.            end;  { if... }
  59.     VK_DOWN: if ssCtrl in Shift then
  60.              begin
  61.                St    := UpperCase (Text);
  62.                St[1] := UpCase (St[1]);
  63.                Text  := St;
  64.                Key  := 0;
  65.              end;  { if... }
  66.   end;  { case }
  67. end;  { TDBEnterEdit.KeyDown }
  68.  
  69. procedure TNewDBGrid.Click;
  70. begin
  71.   inherited Click;
  72.   if assigned (FOnClick) then FOnClick (Self);
  73. end;  { TNewDBGrid.Click }
  74.  
  75. procedure Register;
  76. begin
  77.   RegisterComponents('Domain', [TDBEnterEdit, TNewDBGrid]);
  78. end;
  79.  
  80. end.  { EDSDB }
  81.